home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / clipfp.zip / CLFPCX50.PRG < prev    next >
Text File  |  1991-05-24  |  3KB  |  96 lines

  1. * ------------------------------------------------------------------------
  2. * Module.......: CLPFPCX50.PRG
  3. * Author.......: Pepijn Smits.
  4. * Date.........: Mar 1991
  5. * Copyright....: (c)1991, Pepijn Smits Software.
  6. * Notes........: Clipper 5.01 part of Clipper "Fast" EGA/VGA PCX library.
  7. * ------------------------------------------------------------------------
  8. * FastPCX():    Display a EGA/VGA PCX picture on the screen, quickly..
  9. * returns:    0 = All okay, still in Graph mode, restore with txtMode()!
  10. *        1 - file not found
  11. *        2 - not PCX file!
  12. *        3 - Not proper format (not full screen EGA/VGA PCX file)
  13. * Assumes VGA or EGA installed when PCX file requires one.
  14. * [But that could of Course be checked using Expand's EGAthere()/VGAthere()]
  15.  
  16. Function FastPCX(FileName)
  17. Local Handle := fopen(FileName)
  18. Local Header
  19. Local BPP,X2,Y2            && Bits/Pixel, Lower X and Y
  20. Local Count
  21. Local Palette
  22. Local Buffer
  23. if Handle <= 0
  24.     return 1            && Open Error
  25. else
  26.     Header := Space(128)
  27.     fread(handle,@header,128)
  28.     if SubStr(Header,1,1) <> chr(10)
  29.         fclose(handle)
  30.         return 2        && Not PCX file!
  31.     else
  32.         * - Determine if format Okay, ie. if PCX is:
  33.         * - VGA 320x200x256 or VGA 640x480x16 or EGA 640x350x16
  34.         BPP := Asc(SubStr(Header,4,1))
  35.         X2 := Bin2w(SubStr(Header,9,2))
  36.         Y2 := Bin2w(SubStr(Header,11,2))
  37.  
  38.         if (BPP=8) .and. (X2=319) .and. (Y2=199)
  39.             * - Got a VGA 320x200x256 here..
  40.  
  41.             * - Read the Palette Info
  42.             Palette := Space(768)
  43.             fseek(handle,-768,2)
  44.             fread(handle,@palette,768)
  45.  
  46.             * - Determine length and goto begin picture
  47.             Count := fseek(handle,0,2) - 128 - 768
  48.             buffer := space(Count)
  49.             fseek(handle,128)
  50.  
  51.             * - Set VGA mode, Palette and Draw the picture.
  52.             VGA13mode()
  53.             SetVGAPal(@Palette,256)
  54.             fread(handle,@buffer,Count)
  55.             VGA13Show(@Buffer,Count)
  56.  
  57.         elseif (BPP=1) .and. (X2=639) .and. (Y2=479)
  58.             * - Got a VGA 640x480x16 here..
  59.  
  60.             * - Determine length, and goto begin picture
  61.             Count := fseek(handle,0,2) - 128
  62.             buffer := space(Count)
  63.             fseek(handle,128)
  64.  
  65.             * - Set VGA mode, Palette and Draw the picture.
  66.             VGA12init()
  67.             Palette := SubStr(Header,17,48)
  68.             SetVGAPal(@Palette,16)
  69.             fread(handle,@buffer,Count)
  70.             VGA12Show(@Buffer,Count)
  71.  
  72.         elseif (BPP=1) .and. (X2=639) .and. (Y2=349)
  73.             * - Got a EGA 640x350x16 here..
  74.  
  75.             * - Determine length, and goto begin picture
  76.             Count := fseek(handle,0,2) - 128
  77.             buffer := space(Count)
  78.             fseek(handle,128)
  79.  
  80.             * - Set EGA mode, Palette and draw the picture.
  81.             EGA10init()
  82.             Palette := SubStr(Header,17,48)
  83.             SetEGApal(@Palette)
  84.             fread(handle,@buffer,Count)
  85.             EGA10Show(@Buffer,Count)
  86.  
  87.         else
  88.             * - Nope, no supported picture here
  89.             fclose(handle)
  90.             return 3
  91.         endif
  92.         fclose(handle)
  93.         return 0
  94.     endif
  95. endif
  96.